<form id="<?php echo $uniqid;?>" method="post">
    <div id="goodsedit" class="easyui-tabs">
        <div title="基本信息" style="padding:0;height:600px;">
            <table width="100%" cellspacing="1" cellpadding="5" class="formtable">
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">商品形式：</td>
                    <td>
                        <div style="display: flex;padding-top: 10px">
                            <div class="goods-type" :class="params.type=='normal' ? 'seleted' : ''">
                                <img style="width: 160px;height: 56px;box-sizing: border-box;" src="/images/entity.png" @click="changeType('normal')">
                                <div class="goods-type-selected" style="display: block;" v-if="params.type=='normal'">
                                    <img class="label-auto" src="/static/Easyui/themes/2019/icons/selected.png">
                                </div>
                            </div>
                            <div class="goods-type" :class="params.type=='virtual' ? 'seleted' : ''">
                                <img style="width: 160px;height: 56px;box-sizing: border-box;" src="/images/virtual.png" @click="changeType('virtual')">
                                <div class="goods-type-selected" style="display: block;" v-if="params.type=='virtual'">
                                    <img class="label-auto" src="/static/Easyui/themes/2019/icons/selected.png">
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <input type="hidden" v-model="params.is_package" />
                    <td class="tlabel">商品标题：</td>
                    <td><input type="text" style="width:400px;" v-model="params.title"
                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                               placeholder="请输入标题." required="true"></td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">副标题：</td>
                    <td><input type="text" style="width:400px;" v-model="params.subtitle"
                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                               placeholder=""></td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">商品分类:</td>
                    <td>
                        <select class="item-cat forminput inputstyle" multiple style="width:400px;"></select>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">状态：</td>
                    <td>
                        <div class="display-flex">
                            <el-radio-group v-model="params.status">
                                <el-radio label="up">上架</el-radio>
                                <el-radio label="down">下架</el-radio>
                            </el-radio-group>
                        </div>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">参与业绩计算</td>
                    <td>
                        <div class="display-flex">
                            <el-radio-group v-model="params.calc_consume">
                                <el-radio :label="1">参与</el-radio>
                                <el-radio :label="0">不参与</el-radio>
                            </el-radio-group>
                        </div>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">排序：</td>
                    <td><input type="number" size="20"
                                              class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                              v-model="params.weigh"/></td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">商品主图:</td>
                    <td>
                        <div title="上传图片" class="col-md-12 display-flex">
                            <div class="img-box" v-if="params.image">
                                <a class="linkWrapper" target="_blank" :href="params.image" title="查看原图">
                                    <img height="70px" :src="params.image+'?imageView2/1/w/100/h/100'"></a>
                                <div class="img-box-del" @click="params.image=''">
                                    <img class="label-auto" src="/static/Easyui/themes/2019/icons/del_tr.gif">
                                </div>
                            </div>
                            <div class="add-image-button" v-else>
                                <a class="btn btn-default btn-lg" @click="uploadBox('goodsPackageEditVm.params.image')" href="javascript:void(0);">
                                    <i class="iconfont icon-tianjia"></i>
                                </a>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">轮播图:</td>
                    <td colspan="5">
                        <div class="display-flex">
                            <div class="img-box" v-if="images_arr.length>0" v-for="(vo,index) in images_arr">
                                <a class="linkWrapper" target="_blank" :href="vo" title="查看原图">
                                    <img height="70px" :src="vo+'?imageView2/1/w/100/h/100'"></a>
                                <div class="img-box-del" @click="deleteImages(index)">
                                    <img class="label-auto" src="/static/Easyui/themes/2019/icons/del_tr.gif">
                                </div>
                            </div>
                            <div class="add-image-button">
                                <a class="btn btn-default btn-lg" @click="uploadBox('goodsPackageEditVm.images_arr')" href="javascript:void(0);">
                                    <i class="iconfont icon-tianjia"></i>
                                </a>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">虚拟销量：</td>
                    <td><input type="number" size="20"
                                            class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                            v-model="params.sales"/></td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">浏览人数：</td>
                    <td><input type="number" size="20"
                                                        class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                                        v-model="params.views"/></td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.type=='normal'">
                    <td class="tlabel">配送方式：</td>
                    <td>
                        <label style="margin-right: 20px;">
                            <input type="checkbox" v-model="dispatch_type" class="textbox-prompt"
                                   value="express"/>物流快递</label>
                        <label style="margin-right: 20px;">
                            <input type="checkbox" v-model="dispatch_type" class="textbox-prompt"
                                   value="selfetch"/>到店/自提</label>
                        <label style="margin-right: 20px;">
                            <input type="checkbox" v-model="dispatch_type" class="textbox-prompt"
                                   value="store"/>商家配送</label>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.type=='virtual'">
                    <td class="tlabel">商品类型：</td>
                    <td>
                        <label style="margin-right: 20px;">
                            <input type="checkbox" class="textbox-prompt"
                                   v-model="dispatch_type" value="selfetch"/>到店核销</label>
                        <label style="margin-right: 20px;">
                            <input type="checkbox" class="textbox-prompt"
                                   v-model="dispatch_type" value="autosend"/>自动发货</label>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.type=='normal' && dispatch_type.indexOf('express')>-1">
                    <td class="tlabel">物流快递：</td>
                    <td>
                        <select id="goodsExpressVal" class="forminput inputstyle textbox-text validatebox-text">
                            <template v-for="(vo,index) in expressTemp">
                                <option v-if="dispatch_ids.indexOf(vo.id.toString())>-1" selected :value="vo.id">{{vo.name}}</option>
                                <option v-else :value="vo.id">{{vo.name}}</option>
                            </template>
                        </select>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="dispatch_type.indexOf('selfetch')>-1">
                    <td class="tlabel">到店自提：</td>
                    <td>
                        <select id="goodsSelfetchVal" class="forminput inputstyle textbox-text validatebox-text">
                            <template v-for="(vo,index) in selfetchTemp">
                                <option v-if="dispatch_ids.indexOf(vo.id.toString())>-1" selected :value="vo.id">{{vo.name}}</option>
                                <option v-else :value="vo.id">{{vo.name}}</option>
                            </template>
                        </select>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.type=='normal' && dispatch_type.indexOf('store')>-1">
                    <td class="tlabel">商家配送：</td>
                    <td>
                        <select id="goodsStoreVal" class="forminput inputstyle textbox-text validatebox-text">
                            <template v-for="(vo,index) in storeTemp">
                                <option v-if="dispatch_ids.indexOf(vo.id.toString())>-1" selected :value="vo.id">{{vo.name}}</option>
                                <option v-else :value="vo.id">{{vo.name}}</option>
                            </template>
                        </select>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.type=='virtual' && dispatch_type.indexOf('autosend')>-1">
                    <td class="tlabel">自动发货：</td>
                    <td>
                        <select id="goodsAutosendVal" class="forminput inputstyle textbox-text validatebox-text">
                            <template v-for="(vo,index) in autosendTemp">
                                <option v-if="dispatch_ids.indexOf(vo.id.toString())>-1" selected :value="vo.id">{{vo.name}}</option>
                                <option v-else :value="vo.id">{{vo.name}}</option>
                            </template>
                        </select>
                    </td>
                </tr>
            </table>
            <div style="padding-bottom: 100px;"></div>
        </div>
        <div title="库存及价格" style="padding:0px;display:none;height:600px;">
            <table width="100%" cellspacing="1" cellpadding="5" class="formtable">
                <tr bgcolor="#FFFFFF">
                    <input type="hidden" v-model="params.is_sku">
                    <td class="tlabel">售卖价格：</td>
                    <td><input type="text" style="width:400px;" v-model="params.price"
                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                               placeholder="请输入售卖价格." required="true"> 元</td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">市场价格：</td>
                    <td><input type="text" style="width:400px;" v-model="params.original_price"
                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                               placeholder="请输入市场价格"> 元</td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.is_sku==0">
                    <td class="tlabel">成本价格：</td>
                    <td><input type="text" style="width:400px;" v-model="params.cost_price"
                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                               placeholder="请输入市场价格"> 元</td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.is_sku==0">
                    <td class="tlabel">商品库存：</td>
                    <td><input type="text" style="width:400px;" v-model="skuPrice[0].stock"
                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                               placeholder=""></td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.is_sku==0">
                    <td class="tlabel">库存预警：</td>
                    <td><input type="text" style="width:400px;" v-model="skuPrice[0].stock_warning"
                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                               placeholder=""></td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.is_sku==0">
                    <td class="tlabel">可获积分：</td>
                    <td><input type="text" style="width:400px;" v-model="skuPrice[0].score"
                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                               placeholder=""></td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.is_sku==0">
                    <td class="tlabel">商品重量：</td>
                    <td><input type="text" style="width:400px;" v-model="skuPrice[0].weight"
                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                               placeholder=""></td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.is_sku==0">
                    <td class="tlabel">商品编号：</td>
                    <td><input type="text" style="width:400px;" v-model="skuPrice[0].sn"
                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                               placeholder=""></td>
                </tr>
            </table>
            <div style="padding: 25px;"></div>
        </div>
        <div title="套餐内商品" style="padding:0px;display:none;height:600px;">
            <table width="100%" cellspacing="1" cellpadding="5" class="formtable">
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">套餐形式：</td>
                    <td>
                        <label v-if="params.type === 'normal'" @click="changePackageType(0)" style="padding-left: 20px;">
                            <input name="packageType" type="radio" :checked="params.packageType == '0'" class="textbox-prompt" value="0" >商品组合</label>
                        <label v-if="params.type === 'virtual'" @click="changePackageType(1)" style="padding-left: 20px;">
                            <input name="packageType" type="radio" :checked="params.packageType == '1'" class="textbox-prompt" value="1" >提货卡组合</label>
                        <label v-if="params.type === 'normal'" @click="changePackageType(2)" style="padding-left: 20px;">
                            <input name="packageType" type="radio" :checked="params.packageType == '2'" class="textbox-prompt" value="2" >商品+提货卡组合</label>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.packageType == '0' || params.packageType == '2'">
                    <td class="tlabel">商品组合：</td>
                    <td style="padding-bottom: 20px;">
                        <span class="l-btn l-btn-small color9 table" @click="addInnerGoods"><span class="l-btn-text">添加商品</span></span>
                        <template>
                            <el-table key="innerGoods" :data="innerGoodsListTemp" border empty-text="请选择商品" style="width: 100%; margin-top: 10px;" stripe="true" header-cell-style="text-align:center; padding: 5px 0;" cell-style="padding: 5px 0;">
                                <el-table-column prop="id" label="商品ID" min-width="10%"></el-table-column>
                                <el-table-column label="商品信息" min-width="50%">
                                    <template slot-scope="scope">
                                        <div style="display: flex">
                                            <div style="width: 32px; display: flex; align-items: center;">
                                                <img style="width: 30px; height: 30px; border-radius: 5px; border:1px solid #eee; overflow: hidden;" :src="scope.row.image">
                                            </div>
                                            <div style="width: calc(100% - 42px); text-align: left;">
                                                {{scope.row.title}}
                                            </div>
                                        </div>
                                    </template>
                                </el-table-column>
                                <el-table-column label="数量" min-width="20%">
                                    <template slot-scope="scope">
                                        <el-input-number v-model="scope.row.number" size="mini" :min="1" :max="scope.row.stock>999?999:scope.row.stock" label="商品数量"></el-input-number>
                                    </template>
                                </el-table-column>
                                <el-table-column label="操作" min-width="20%">
                                    <template slot-scope="scope">
                                        <el-button size="mini" type="danger" @click="innerGoodsRemove(scope.$index, scope.row)">移除</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </template>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF" v-if="params.packageType == '1' || params.packageType == '2'">
                    <td class="tlabel">提货卡组合：</td>
                    <td style="padding-bottom: 20px;">
                        <span class="l-btn l-btn-small color9 table" @click="addInnerCard"><span class="l-btn-text">添加提货卡</span></span>
                        <template>
                            <el-table key="innerCards" :data="innerPickGoodsCardTemp" border empty-text="请选择提货卡" style="width: 100%; margin-top: 10px;" stripe="true" header-cell-style="text-align:center; padding: 5px 0;" cell-style="padding: 5px 0;">
                                <el-table-column prop="id" label="提货卡ID" min-width="10%"></el-table-column>
                                <el-table-column label="提货卡信息" min-width="50%">
                                    <template slot-scope="scope">
                                        <p>名称：{{scope.row.name}}</p>
                                        <p>面额：{{scope.row.amount}}元</p>
                                    </template>
                                </el-table-column>
                                <el-table-column label="数量" min-width="20%">
                                    <template slot-scope="scope">
                                        <el-input-number v-model="scope.row.number" size="mini" :min="1" :max="999" label="提货卡数量"></el-input-number>
                                    </template>
                                </el-table-column>
                                <el-table-column label="操作" min-width="20%">
                                    <template slot-scope="scope">
                                        <el-button size="mini" type="danger" @click="innerCardRemove(scope.$index, scope.row)">移除</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </template>
                    </td>
                </tr>
            </table>
        </div>
        <div title="商品详情" style="padding:0px;display:none;height:600px;">
            <table width="100%" cellspacing="1" cellpadding="5" class="formtable">
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">服务标签：</td>
                    <td>
                        <label v-for="(vo,index) in goodsService">
                            <input name="goodsService" type="checkbox" class="textbox-prompt" v-model="service_ids" :value="vo.id">{{ vo.name }}
                        </label>

                        <span class="l-btn l-btn-small color9 table" @click="addService"><span class="l-btn-text">添加标签</span></span>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td class="tlabel">参数详情：</td>
                    <td>
                        <div class="" v-for="(s, k) in parameters" style="width: 80%;">
                            <div class="display-flex sku-item" style="justify-content: space-between; background-color: #F5F5F5;">
                                <div class="display-flex">
                                    <div style="padding:0 20px;">
                                        <input type="text" style="width:200px;" v-model="s.key"
                                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                               placeholder="请输入参数名称." required="true">
                                    </div>
                                    <div style="width: 120px;">
                                        <input type="text" style="width:500px;" v-model="s.val"
                                               class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
                                               placeholder="请输入参数详情." required="true">
                                    </div>
                                </div>
                                <div style="width: 20px;height: 20px;" @click="delParams(k)">
                                    <img class="label-auto" src="/static/Easyui/themes/2019/icons/del_tr.gif">
                                </div>
                            </div>
                        </div>
                        <span class="l-btn l-btn-small color9 table" @click="addParams"><span class="l-btn-text">添加参数</span></span>
                    </td>
                </tr>
                <tr bgcolor="#FFFFFF">
                    <td colspan="2">
                        <script id="goodsPackageEditor" type="text/plain">{{ params.content }}</script>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div style="position:absolute;z-index: 9999; bottom:0;width:100%; text-align:right; background-color:#F1f1f1; border:#ccc 1px solid;">
        <div style="padding:2px 15px 2px 10px; float:right;">
            <a v-if="step<3" class="l-btn l-btn-small" href="javascript:void(0);" @click="nextStep"><span
                        class="l-btn-left l-btn-icon-left"><span class="l-btn-text">下一步</span><span
                        class="l-btn-icon icon-ok">&nbsp;</span></span></a>
            <a v-else href="javascript:void(0);" class="l-btn l-btn-small" @click="goodseditsubmitForm()"><span
                    class="l-btn-left l-btn-icon-left"><span class="l-btn-text">确定</span><span
                    class="l-btn-icon icon-ok">&nbsp;</span></span></a>
            <a href="javascript:void(0);" class="l-btn l-btn-small" @click="goodseditclearForm()"><span
                    class="l-btn-left l-btn-icon-left"><span class="l-btn-text">关闭</span><span
                    class="l-btn-icon icon-no">&nbsp;</span></span></a>
        </div>
    </div>
</form>
<div id="goodsPackageEditdlg" class="easyui-dialog" style="width:700px; height:580px;" title="信息框" closed="true"></div>
<script>
    var goodsPackageEditVm = new Vue({
        el: '#<?php echo $uniqid;?>',
        data: {
            step: 0,
            type: 'edit',
            dispatch_type: [],
            dispatch_ids: [],
            service_ids: [],
            parameters: [],
            params: JSON.parse('<?php echo addslashes($dataset);?>'),
            expressTemp: JSON.parse('<?php echo addslashes($expressTemp);?>'),
            storeTemp: JSON.parse('<?php echo addslashes($storeTemp);?>'),
            selfetchTemp: JSON.parse('<?php echo addslashes($selfetchTemp);?>'),
            autosendTemp: JSON.parse('<?php echo addslashes($autosendTemp);?>'),
            categoryTree: JSON.parse('<?php echo $categoryTree;?>'),
            skuPrice: JSON.parse('<?php echo addslashes($skuPrice);?>'),
            goodsService: JSON.parse('<?php echo addslashes($goodsService);?>'),
            innerPickGoodsCardIds:[],
            innerGoodsIds:[],
            innerPickGoodsCardTemp:[],
            innerGoodsListTemp:[],
            skuModal: '',
            childrenModal: [],
            images_arr: [],
            countId: 1,
            allEditSkuName: '',
            isEditInit: false, // 编辑时候初始化是否完成
            isResetSku: 0,
        },
        mounted() {
            this.init();
        },
        methods: {
            updateVMData() {
                this.$forceUpdate();
            },
            init(){
                $('#<?php echo $uniqid;?> .item-cat').combotree({
                    data: this.categoryTree,
                    panelHeight: 300,
                    checkbox: true
                });
                if (parseInt(this.params.category_ids)>0) {
                    $('#<?php echo $uniqid;?> .item-cat').combotree('setValues', this.params.category_ids.split(','));
                }
                this.images_arr = this.params.images ? this.params.images : [];
                if(!this.params.id){
                    this.isEditInit = true;
                }
                this.params.is_package = 1;
                this.params.is_sku = 0;
                this.parameters = this.params.params ? this.params.params : [];
                this.dispatch_type = this.params.dispatch_type ? this.params.dispatch_type.split(',') : [];
                this.dispatch_ids = this.params.dispatch_ids ? this.params.dispatch_ids.split(',') : [];
                this.service_ids = this.params.service_ids ? this.params.service_ids.split(',') : [];
                if(this.params.id>0 && this.params.get_goods_package_info){
                    this.params.goods_package_id = this.params.get_goods_package_info.id;
                    if(this.params.type === 'normal'){
                        if(this.params.get_goods_package_info.card_info_arr.length && this.params.get_goods_package_info.package_goods_arr.length){
                            this.params.packageType = '2';
                        }
                    }else{
                        this.params.packageType = '1';
                    }
                    if(this.params.get_goods_package_info.card_info_arr.length){
                        for (let i = 0; i < this.params.get_goods_package_info.card_info_arr.length; i++){
                            this.innerPickGoodsCardIds.push(parseInt(this.params.get_goods_package_info.card_info_arr[i].id));
                            this.innerPickGoodsCardTemp.push(this.params.get_goods_package_info.card_info_arr[i]);
                        }
                    }
                    if(this.params.get_goods_package_info.package_goods_arr.length){
                        for (let i = 0; i < this.params.get_goods_package_info.package_goods_arr.length; i++){
                            this.innerGoodsIds.push(parseInt(this.params.get_goods_package_info.package_goods_arr[i].id));
                            this.innerGoodsListTemp.push(this.params.get_goods_package_info.package_goods_arr[i]);
                        }
                    }
                    delete this.params.get_goods_package_info;
                }
                this.updateVMData();
            },
            deleteImages(index){
                this.images_arr.splice(index, 1);
            },
            addService() {
                addTab('服务标签', '/admin/goodsservice/index');
            },
            //添加参数
            addParams(){
                this.parameters.push({key:'', val:''});
            },
            delParams(idx){
                this.parameters.splice(idx, 1);
            },
            changeType(goodsType){
                if(goodsType == 'normal'){
                    if(this.params.packageType = '1'){
                        this.params.packageType = '0';
                    }
                }else {
                    this.params.packageType = '1';
                }
                this.params.type = goodsType;
                this.updateVMData();
            },
            changePackageType(value){
                if(this.params.type === 'normal'){
                    this.params.packageType = value?value:0;
                }else {
                    this.params.packageType = value?value:1;
                }
                this.updateVMData();
            },
            addInnerCard(){
                $("#goodsPackageEditdlg").dialog({
                    title: '选择提货卡',
                    closed: false,
                    width: 800,
                    height:638,
                    cache: false,
                    href: '/admin/goodspackage/getpickgoodscardlist',
                    modal: true,
                    buttons:[{
                        text:'确定',
                        id:'goodsPackageAddGoodsCardSelectSubmit',
                        iconCls:'icon-ok',
                    },{
                        text:'关闭',
                        iconCls:'icon-no',
                        handler:function(){
                            $("#goodsPackageEditdlg").dialog('close');
                        }
                    }]
                });
            },
            addInnerGoods(){
                $("#goodsPackageEditdlg").dialog({
                    title: '选择商品',
                    closed: false,
                    width: 800,
                    height:638,
                    cache: false,
                    href: '/admin/goodspackage/getgoodslist',
                    modal: true,
                    buttons:[{
                        text:'确定',
                        id:'goodsPackageAddGoodsSelectSubmit',
                        iconCls:'icon-ok',
                    },{
                        text:'关闭',
                        iconCls:'icon-no',
                        handler:function(){
                            $("#goodsPackageEditdlg").dialog('close');
                        }
                    }]
                });
            },
            innerCardRemove(index, row){
                if(this.innerPickGoodsCardIds.length > 1){
                    if(index > -1 && row.id === this.innerPickGoodsCardIds[index]){
                        this.innerPickGoodsCardTemp.splice(index, 1);
                        this.innerPickGoodsCardIds.splice(index, 1);
                    }
                }else{
                    $.messager.alert('提示', '最少需要保留1张提货卡！','warning');
                }
            },
            innerGoodsRemove(index, row){
                if(this.innerGoodsIds.length > 1){
                    if(index > -1 && row.id === this.innerGoodsIds[index]){
                        this.innerGoodsListTemp.splice(index, 1);
                        this.innerGoodsIds.splice(index, 1);
                    }
                }else{
                    $.messager.alert('提示', '最少需要保留1个商品！','warning');
                }
            },
            nextStep(){
                ++this.step;
                $('#goodsedit').tabs('select', this.step);
            },
            goodseditclearForm () {
                let title = this.params.id?'编辑商品套餐':'新增商品套餐';
                $('#goodseditfm').form('clear');
                $('#rightTabs').tabs('close', title);
            },
            goodseditsubmitForm () {
                if(!this.params.title){
                    $.messager.alert('提示','商品标题为空','warning');
                    return;
                }
                if(!this.params.image){
                    $.messager.alert('提示','商品主图为空','warning');
                    return;
                }
                if(!this.dispatch_type){
                    $.messager.alert('提示','配送方式未选','warning');
                    return;
                }
                this.params.dispatch_type = this.dispatch_type.join(',');
                let dispatch_ids = [];
                if(this.dispatch_type.indexOf('express')>-1 && $('#goodsExpressVal').val()) {
                    dispatch_ids.push($('#goodsExpressVal').val());
                }
                if(this.dispatch_type.indexOf('store')>-1 && $('#goodsStoreVal').val()) {
                    dispatch_ids.push($('#goodsStoreVal').val());
                }
                if(this.dispatch_type.indexOf('selfetch')>-1 && $('#goodsSelfetchVal').val()) {
                    dispatch_ids.push($('#goodsSelfetchVal').val());
                }
                if(this.dispatch_type.indexOf('autosend')>-1 && $('#goodsAutosendVal').val()) {
                    dispatch_ids.push($('#goodsAutosendVal').val());
                }
                this.params.dispatch_ids = dispatch_ids.join(',');
                let itemCat = $('#<?php echo $uniqid;?> .item-cat').combotree('getValues');
                this.params.category_ids = itemCat.join(',');
                this.params.images = this.images_arr.join(',');
                this.params.service_ids = this.service_ids.join(',');
                this.params.params = JSON.stringify(this.parameters);
                this.params.content= goodsPackageEditorUm.getContent();
                if(this.innerGoodsListTemp.length){
                    for (let i = 0; i< this.innerGoodsListTemp.length; i++){
                        this.params.innerGoods.push({'id':this.innerGoodsListTemp[i].id,'number':this.innerGoodsListTemp[i].number});
                    }
                }
                if(this.innerPickGoodsCardTemp.length){
                    for (let i = 0; i< this.innerPickGoodsCardTemp.length; i++){
                        this.params.innerCards.push({'id':this.innerPickGoodsCardTemp[i].id,'number':this.innerPickGoodsCardTemp[i].number});
                    }
                }
                $.messager.progress();
                let act = this.params.id>0 ? 'edit' : 'add';
                let title = this.params.id>0?'编辑商品套餐':'新增商品套餐';
                $.post('/admin/goodspackage/'+act, {params: this.params, skuPrice: this.skuPrice}, (data)=>{
                    $.messager.progress('close');
                    if(parseInt(data.ret)===0){
                        $.messager.show({
                            title:'提示',
                            msg:data.msg,
                            timeout:3000,
                            showType:'slide'
                        });
                        if (typeof(goodsPackageReload)=='function'){
                            goodsPackageReload();
                        }
                        $('#rightTabs').tabs('close', title);
                    }else{
                        $.messager.alert('提示',data.msg,'warning');
                    }
                },'json');
            },
        }
    });
    if (typeof(goodsPackageEditorUm) != 'undefined') {
        goodsPackageEditorUm.destroy();
    }
    var goodsPackageEditorUm = UE.getEditor('goodsPackageEditor', {initialFrameHeight: 400, autoHeightEnabled: false});
    $('#goodsedit').tabs({
        onSelect(title, index){
            goodsPackageEditVm.step = index;
        }
    });
</script>

<style>
    .pointer{cursor:pointer}
    .goods-type {
        width: 162px;
        height: 58px;
        border-radius: 4px;
        position: relative;
        margin-right: 20px;
    }
    .goods-type-selected {
        width: 16px;
        height: 16px;
        line-height: 16px;
        text-align: center;
        border-radius: 50%;
        background: #7438D5;
        color: #fff;
        font-weight: 600;
        font-size: 14px;
        display: none;
        position: absolute;
        top: -8px;
        right: -8px;
    }
    .seleted{
        border: #ff6600 2px solid;
    }
</style>